#include "FileDialog.h"
#include "FileBrowser.h"

QString un_utf8(const char*ChineseString);

FileDialog::FileDialog(const QString &Title,const QString &Type,QWidget *parent , const char *name)
  :UTIL_Dialog(UTIL_Dialog::DTLargeSize,true, parent,name,ZBaseDialog::APP_MODAL,0)
{
	 setHasTitle(true);
	 setDlgTitle(Title);

	 FileDlg = new FileBrowser( "ezx_util_list" , this);
  FileDlg->setFilter(Type);
  FileDlg->setDir("/mmc/mmca1");

	 setDlgContent(FileDlg);

  QFrame *cstFrame = (QFrame*)getDlgCst();
	
	 ZPushButton *OkBtn = new ZPushButton( "", tr("OK"), cstFrame, 0, 0, 0);
	 OkBtn->setGeometry(ZGlobal::mapFromGlobalR(OkBtn, ZGlobal::getDlgA2a_1R())); // DlgA Layout rules
  QObject::connect(OkBtn, SIGNAL(clicked()), this, SLOT(accept()));
	
 	ZPushButton *ClearBtn = new ZPushButton( "", tr("Cancel"), cstFrame, 0, 0, 0);
	 ClearBtn->setGeometry(ZGlobal::mapFromGlobalR(ClearBtn, ZGlobal::getDlgA2a_2R()));
  QObject::connect(ClearBtn, SIGNAL(clicked()), this, SLOT(reject()));
}
FileDialog::~FileDialog()
{
}
void FileDialog::setFilter(const QString &type)
{
  FileDlg->setFilter(type);
}
QString FileDialog::getFileName()
{
  return FileDlg->getFileName();
}
QString FileDialog::getFilePath()
{
  return FileDlg->getFilePath();
}
QStringList FileDialog::getFileListPath()
{
  return FileDlg->SelectedList(File);
}
